package com.nlp.controller;

import java.util.Map;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.nlp.utils.SendMessage;

@RestController
@RequestMapping(value = "/robot")
public class RobotController {

	@RequestMapping(value = "/answer", method = RequestMethod.POST)
	public String getRes(@RequestBody Map<String, String> query) {
		String parm = "{\"version\":\"2.0\",\"service_id\":\"S14914\",\"log_id\":\"123\",\"session_id\":\"\",\"interactions\":[],\"request\":{\"user_id\":\"123456\",\"query\":\""+query.get("query")+"\"}}";
		String url = "https://aip.baidubce.com/rpc/2.0/unit/service/chat?access_token=24.d944b13baed4f88d92b5f0ffa114f0d6.2592000.1554952732.282335-15729350";
		String res = SendMessage.translateByPost(url, parm);
//		System.out.println(res);
		return res;
	}
}
